﻿<UserControl 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.RoleDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight" 
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:Controls1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common" 
    navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.RoleDetailViewModel"
    >

    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
    </UserControl.Resources>

    <telerik:RadBusyIndicator
        BusyContent="Đang kết nối tới máy chủ..."
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}"
        >
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!--Title-->
            <Grid Grid.ColumnSpan="4">
                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>

                <TextBlock 
                        x:Name="lblTitle" 
                        Style="{StaticResource TextBlockTitlePageStyle}"                   
                        Text="Thông tin chức vụ"/>
            </Grid>

            <TControls:RadTabControl                
                Grid.Row="2"  Grid.Column="0" Grid.ColumnSpan="3"
                Background="Transparent"
                >
                <TControls:RadTabItem
                    Header="Thông tin chung"
                    Background="Transparent"
                    >

                    <Grid 
                        Background="Transparent"
                        Grid.Row="2" Grid.Column="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock 
                            Grid.Row="0" Grid.Column="1"
                            Style="{StaticResource TextBlockNormalStyle}"
                            >
                            <Run Text="{StaticResource RoleCodeLabelText}" />
                            <Run Text=" *" Foreground="Red" />
                        </TextBlock>
                        <TextBox 
                            Grid.Row="0" Grid.Column="2"
                            Style="{StaticResource TextBoxNormalStyle}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Role.RoleCode, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <TextBlock 
                            Grid.Row="1" Grid.Column="1"
                            Style="{StaticResource TextBlockNormalStyle}"
                            >
                            <Run Text="{StaticResource RoleNameLabelText}" />
                            <Run Text=" *" Foreground="Red" />
                        </TextBlock>
                        <TextBox 
                            Grid.Row="1" Grid.Column="2"
                            Style="{StaticResource TextBoxNormalStyle}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Role.RoleName, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <TextBlock 
                            Grid.Row="0" Grid.Column="3"
                            x:Name="lblcDescription"
                            Style="{StaticResource TextBlockNormalStyle}"
                            >
                            <Run Text="{StaticResource BriefDescriptionLabelText}" />
                            <Run Text=" *" Foreground="Red" />
                        </TextBlock>
                        <TextBox 
                            Grid.Row="0" Grid.Column="4" Grid.RowSpan="2" 
                            x:Name="txtcDescription"                
                            Style="{StaticResource TextBoxMultilineStyle}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Role.BriefDescription, Mode=TwoWay, ValidatesOnDataErrors=True}" />

                        <!--<TextBlock 
                            Grid.Row="4" Grid.Column="0"
                            Style="{StaticResource TextBlockNormalStyle}"
                            >
                            <Run Text="{StaticResource FullDescriptionLabelText}" />
                            <Run Text=" *" Foreground="Red" />
                        </TextBlock>
                        <RichTextBox 
                            BorderThickness="1"
                            BorderBrush="Gray"
                            Grid.Row="4" Grid.Column="1" Grid.RowSpan="2" Grid.ColumnSpan="3"    
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}"             
                            Style="{StaticResource TRichTextBoxStyle}"
                            DataContext="{Binding Path=Role.FullDecription, Mode=TwoWay, ValidatesOnDataErrors=True}"/>-->
                    </Grid>

                </TControls:RadTabItem>

                <TControls:RadTabItem
                    Header="Tác vụ mặc định" Visibility="Collapsed"
                    Background="Transparent">
                    <Controls1:RadGridView
                        telerik:StyleManager.Theme="Office_Black"
                        Style="{StaticResource RadGridViewNormal}"
                        ItemsSource="{Binding Path=AuthorizationCollection}"
                        >
                        <Controls1:RadGridView.Columns>
                            <Controls1:GridViewColumn
                                Header="Chọn">
                                <Controls1:GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox
                                            HorizontalAlignment="Center"
                                            IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"
                                            IsEnabled ="{Binding Path=DataSource.CanEditOrAdd, Mode=OneWay, Source={StaticResource DataContextProxy}}" 
                                            Command="{Binding Path=DataSource.SelectCommand, Source={StaticResource DataContextProxy}}"
                                            CommandParameter="{Binding Path=AuthorizationID}"
                                        />
                                    </DataTemplate>
                                </Controls1:GridViewColumn.CellTemplate>
                            </Controls1:GridViewColumn>
                            <Controls1:GridViewDataColumn 
                                Header="Tác vụ" 
                                DataMemberBinding="{Binding Path=Description}"
                                />
                        </Controls1:RadGridView.Columns>
                    </Controls1:RadGridView>
                </TControls:RadTabItem>

            </TControls:RadTabControl>

            <!--Message-->
            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="4"
                Style="{StaticResource ErrorMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=ErrorMessageVisibility, Mode=TwoWay}"
            />

            <TextBlock
                HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="3"
                Style="{StaticResource SuccessfulMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=MessageVisibility, Mode=TwoWay}"
                />

            <!--Buttons-->
            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3">
                <!--Buttons-->
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    />
            </StackPanel>
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
